package com.usermanage.controller;

import com.usermanage.Service.OperationService;
import com.usermanage.beanParam.OperationBean;
import com.usermanage.util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 *一元操作接口
 */
@Api(description = "一元操作接口")
@RestController
@RequestMapping("/operation")
public class OperationController {

    @Resource
    private OperationService operationService;




    @ApiOperation(value = "根据合作细节id添加一元操作" ,  notes="根据合作细节id添加一元操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "operationDetailId", value = "操作详情id", required = true,  paramType = "query", dataType = "String")
    })
    @RequestMapping(value="/creatOperation",method= RequestMethod.POST)
    public JsonData creatOperation(@Valid @RequestBody OperationBean bean, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return JsonData.fail(bindingResult.getFieldError().getDefaultMessage());
        }
        //验证对象操作是否存在
//        Boolean bool = operationService.isExistOperation("");
//        if (bool){
//            return JsonData.fail("一元操作已存在");
//        }
        //创建一个对象操作
//        int result = operationService.creatOperation(operationBean);
//        if (result == 0){
//            return JsonData.fail("一元操作创建失败，系统异常！");
//        }
        return JsonData.success();
    }

}
